package LEETCODE2023.BISHUA100;

public class SolutionBM83 {
    public static void main(String[] args) {
        System.out.println("mbby".charAt(3));
        String s = "h i ";
        System.out.println(trans(s, s.length()));
    }

    public static String trans(String s, int n) {
        StringBuilder sb = new StringBuilder(s);
        StringBuilder ans = new StringBuilder();
        int head = n - 1;
        while (head >= 0) {
            StringBuilder temp = new StringBuilder();
            while (head >= 0 && sb.charAt(head) != ' ') {
                char x = sb.charAt(head);
                if (x >= 'a' && x <= 'z')
                    temp.append((char) (x - 'a' + 'A'));
                else {
                    temp.append((char) (x + 'a' - 'A'));
                }
                head--;
            }
            ans.append(temp.reverse());
            ans.append(' ');
            head--;
        }
        if(sb.charAt(0)!=' '){
            ans.deleteCharAt(ans.length() - 1);
        }
        return ans.toString();
    }
}
